From 7184ccd780f046258fdf6c4e67d10547411cfcce Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 19 Aug 2005 09:16:56 +0000 Subject: [PATCH] Default unit for all Xen memory parameters is kilobytes. Signed-off-by: Keir Fraser --- docs/src/user.tex | 2 +- xen/arch/x86/domain_build.c | 11 +++-------- xen/common/lib.c | 4 +++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/src/user.tex b/docs/src/user.tex index da41a813dc..3ee4a24fbc 100644 --- a/docs/src/user.tex +++ b/docs/src/user.tex @@ -1763,7 +1763,7 @@ editing \path{grub.conf}. physical address in the memory map will be ignored. This parameter may be specified with a B, K, M or G suffix, representing bytes, kilobytes, megabytes and gigabytes respectively. The - default unit, if no suffix is specified, is bytes. + default unit, if no suffix is specified, is kilobytes. \item [dom0\_mem=xxx ] Set the amount of memory to be allocated to domain0. In Xen 3.x the parameter diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index b9941763c4..cc3f3b6d78 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -22,16 +22,11 @@ #include #include -/* opt_dom0_mem: memory allocated to domain 0. */ -static unsigned int opt_dom0_mem; +static unsigned long dom0_nrpages; static void parse_dom0_mem(char *s) { unsigned long long bytes = parse_size_and_unit(s); - /* If no unit is specified we default to kB units, not bytes. */ - if ( isdigit(s[strlen(s)-1]) ) - opt_dom0_mem = (unsigned int)bytes; - else - opt_dom0_mem = (unsigned int)(bytes >> 10); + dom0_nrpages = bytes >> PAGE_SHIFT; } custom_param("dom0_mem", parse_dom0_mem); @@ -139,7 +134,7 @@ int construct_dom0(struct domain *d, /* By default DOM0 is allocated all available memory. */ d->max_pages = ~0U; - if ( (nr_pages = opt_dom0_mem >> (PAGE_SHIFT - 10)) == 0 ) + if ( (nr_pages = dom0_nrpages) == 0 ) nr_pages = avail_domheap_pages() + ((initrd_len + PAGE_SIZE - 1) >> PAGE_SHIFT) + ((image_len + PAGE_SIZE - 1) >> PAGE_SHIFT); diff --git a/xen/common/lib.c b/xen/common/lib.c index 764ad7143d..1eb70fe6c4 100644 --- a/xen/common/lib.c +++ b/xen/common/lib.c @@ -450,8 +450,10 @@ unsigned long long parse_size_and_unit(char *s) ret <<= 10; case 'M': case 'm': ret <<= 10; - case 'K': case 'k': + case 'K': case 'k': default: ret <<= 10; + case 'B': case 'b': + break; } return ret; -- 2.30.2